package com.ruoyi.web.controller.cs;

import java.util.List;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.common.utils.poi.Excel2Util;
import com.ruoyi.cs.domain.TBattleBox;
import com.ruoyi.cs.domain.TBattleUser;
import com.ruoyi.cs.service.ITBattleUserService;
import com.ruoyi.system.domain.SysConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 对战用户信息Controller
 * 
 * @author ruoyi
 * @date 2021-08-05
 */
@Api(tags = {"对战用户信息"})
@RestController
@RequestMapping("/cs/battleuser")
public class TBattleUserController extends BasicsController
{
    @Autowired
    private ITBattleUserService tBattleUserService;

    /**
     * 查询对战用户信息列表
     */
    @ApiOperation("查询对战用户信息列表")
    @PreAuthorize("@ss.hasPermi('cs:battleuser:list')")
    @GetMapping("/list")
    public ResponsePageInfo<TBattleUser> list(TBattleUser tBattleUser)
    {
        startPage();
        List<TBattleUser> list = tBattleUserService.selectTBattleUserList(tBattleUser);
        return toResponsePageInfo(list);
    }

    /**
     * 导出对战用户信息列表
     */
    @ApiOperation("导出对战用户信息列表")
    @PreAuthorize("@ss.hasPermi('cs:battleuser:export')")
    @Log(title = "对战用户信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public Response<String> export(TBattleUser tBattleUser)
    {
        List<TBattleUser> list = tBattleUserService.selectTBattleUserList(tBattleUser);
        Excel2Util<TBattleUser> util = new Excel2Util<TBattleUser>(TBattleUser.class);
        return util.exportExcel(list, "user");
    }

    /**
     * 获取对战用户信息详细信息
     */
    @ApiOperation("获取对战用户信息详细信息")
    @PreAuthorize("@ss.hasPermi('cs:battleuser:query')")
    @GetMapping(value = "/{battleruserId}")
    public Response<TBattleUser> getInfo(
            @ApiParam(name = "battleruserId", value = "对战用户信息ID", required = true)
            @PathVariable("battleruserId") String battleruserId)
    {
        return Response.success(tBattleUserService.selectTBattleUserById(battleruserId));
    }

    /**
     * 新增对战用户信息
     */
    @ApiOperation("新增对战用户信息")
    @PreAuthorize("@ss.hasPermi('cs:battleuser:add')")
    @Log(title = "对战用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public Response<Integer> add(@RequestBody TBattleUser tBattleUser)
    {
        return toResponse(tBattleUserService.insertTBattleUser(tBattleUser));
    }

    /**
     * 修改对战用户信息
     */
    @ApiOperation("修改对战用户信息")
    @PreAuthorize("@ss.hasPermi('cs:battleuser:edit')")
    @Log(title = "对战用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public Response<Integer> edit(@RequestBody TBattleUser tBattleUser)
    {
        return toResponse(tBattleUserService.updateTBattleUser(tBattleUser));
    }

    /**
     * 删除对战用户信息
     */
    @ApiOperation("删除对战用户信息")
    @PreAuthorize("@ss.hasPermi('cs:battleuser:remove')")
    @Log(title = "对战用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{battleruserIds}")
    public Response<Integer> remove(
            @ApiParam(name = "battleruserIds", value = "需要删除的对战用户信息ID", required = true)
            @PathVariable String[] battleruserIds)
    {
        return toResponse(tBattleUserService.deleteTBattleUserByIds(battleruserIds));
    }
}
